﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Common;
using System.Data.Entity;
using System.Data.Entity.ModelConfiguration;
using System.Data.Entity.Infrastructure;
using DLM.Domain.Model;

namespace DLM.Data.EF.CodeFirst.Mapping
{
    public class MessageMap : EntityTypeConfiguration<Message>
    {
        public MessageMap()
        {
            this.HasKey(t => t.MessageID);
            this.ToTable("Message");
            this.Property(t => t.MessageID).HasColumnName("MessageID").HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.Property(t => t.UserID).HasColumnName("UserID");
            this.Property(t => t.Title).HasColumnName("Title").IsRequired().HasMaxLength(20);
            this.Property(t => t.Content).HasColumnName("Content");
            this.Property(t => t.IsRead).HasColumnName("IsRead");
            this.Property(t => t.Source).HasColumnName("Source").HasMaxLength(25);
            this.Property(t => t.CreateDate).HasColumnName("CreateDate");
            this.HasRequired(t => t.User).WithMany(t => t.Message).HasForeignKey(d => d.UserID);
        }
    }
}
